package com.landscope.issue.controller.api;

import com.landscope.issue.controller.api.dto.LoginDto;
import com.landscope.issue.controller.api.param.LoginParam;
import com.landscope.issue.controller.base.ResponseResult;
import com.landscope.issue.service.ApiUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户接口
 * @author qzp
 * @version v1.0
 * @date 2021/7/31 23:50
 **/
@RequestMapping("api/m/user")
@RestController
@Api(tags = "1.用户")
@CrossOrigin
public class ApiUserController {

    @Resource
    private ApiUserService apiUserService;

    /**
     * 登录
     * @return {@link * @return java.lang.Object}
     * @throws
     * @author 瞿子朋
     * @date 2021/8/2 9:58
     * @version v1.0
     **/
    @ApiOperation(value = "1.1 登录",notes = "登录")
    @PostMapping("/login")
    public ResponseResult<LoginDto> login(@RequestBody LoginParam param){
        return apiUserService.login(param);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token", dataType = "String")
    })
    @ApiOperation(value = "1.2 退出登录",notes = "退出登录")
    @PostMapping("/logout")
    public ResponseResult logout(){
        return apiUserService.logout();
    }
}
